# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=pygithub
_pyname=PyGithub
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.59.1
pkgrel=1
pkgdesc="Use the full Github API v3 (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://github.com/PyGithub/PyGithub/"
license=('spdx:LGPL-3.0' 'spdx:GPL-3.0')
depends=("${MINGW_PACKAGE_PREFIX}-python-deprecated"
         "${MINGW_PACKAGE_PREFIX}-python-pyjwt"
         "${MINGW_PACKAGE_PREFIX}-python-requests"
         "${MINGW_PACKAGE_PREFIX}-python-pynacl")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools-scm"
             "${MINGW_PACKAGE_PREFIX}-python-wheel")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-cryptography"
              "${MINGW_PACKAGE_PREFIX}-python-httpretty"
              "${MINGW_PACKAGE_PREFIX}-python-parameterized")
source=("https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('c44e3a121c15bf9d3a5cc98d94c9a047a5132a9b01d22264627f58ade9ddc217')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "PyGithub-${pkgver}" "python-build-${MSYSTEM}"
}


build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m pytest
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -vDm644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/COPYING"
}
